/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MessageFrame.java
 *
 * Created on Jun 20, 2009, 8:50:05 PM
 */

package ces31.ChineseDicesClient.IU;

import ces31.ChineseDicesClient.SO_SistemaCliente;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Douglas
 */
public class IU_Mensagem extends javax.swing.JFrame {

    /** Creates new form MessageFrame */
    public IU_Mensagem(String message) {
        setMensagem(message);
        initComponents();
        this.setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        areaMensagem = new javax.swing.JLabel();
        botaoOK = new javax.swing.JToggleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        areaMensagem.setText(getMensagem());
        areaMensagem.setName("areaMensagem"); // NOI18N

        botaoOK.setText("OK");
        botaoOK.setName("botaoOK"); // NOI18N
        botaoOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharTela(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addComponent(botaoOK, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(areaMensagem, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(areaMensagem)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(botaoOK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void fecharTela(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharTela
        botaoOK.setEnabled(false);
        this.setVisible(false);
        try {
            SO_SistemaCliente.getSalaDeEspera().desconectarCliente();
            this.finalize();
        } catch (Throwable ex) {
            Logger.getLogger(IU_Mensagem.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_fecharTela


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel areaMensagem;
    private javax.swing.JToggleButton botaoOK;
    // End of variables declaration//GEN-END:variables

    private String mensagem;

    public String getMensagem() {
        return mensagem;
    }

    public void setMensagem(String message) {
        this.mensagem = message;
    }

}
